﻿using umbraco.cms.presentation.Trees;


namespace ClientTools.Section.LogViewer
{
    public class LoadLogViewer: BaseTree
    {
        public LoadLogViewer(string application) : base(application)
        {
        }
        
        protected override void CreateRootNode(ref XmlTreeNode rootNode)
        {
            rootNode.Text = "LogViewer";
            rootNode.Icon = FolderIcon;
            rootNode.OpenIcon = FolderIconOpen;
            rootNode.NodeType = string.Format("init{0}", TreeAlias);
            rootNode.NodeID = "-1";
            rootNode.Action = string.Format("javascript:LogViewer();");

            rootNode.Menu.Clear();
        }

        public override void Render(ref XmlTree tree)
        {
            //var xNode = XmlTreeNode.Create(this);
            //xNode.NodeID = "2";
            //xNode.Text = "Test";
            //xNode.Icon = FolderIcon;
            //xNode.OpenIcon = FolderIconOpen;
            //xNode.Action = string.Format("javascript:LogViewer();");
            //xNode.Menu.Clear();
            //tree.Add(xNode);

            //throw new NotImplementedException();
        }

        public override void RenderJS(ref System.Text.StringBuilder javascript)
        {
            javascript.Append(
                @"
                    function LogViewer() {
	                    parent.right.document.location.href = 'plugins/ClientTools/LogViewer.aspx';
                    }
                ");
        }
    }
}
